import React, { useEffect } from 'react'

let observer
export default function useObserveHooks(ele, callbak, watch = []) {
    useEffect(() => {
        let node = document.getElementById(ele)
        if (node) {
            observer = new IntersectionObserver(entries => {
                callbak && callbak(entries)
            })
            observer.observe(node)
        }
        return () => {
            if (observer && node) {
                observer.unobserver(node)
                observer.disconnect()
            }
        }
    }, watch)
    return (
        <div>

        </div>
    )
}
